package com.doupi.partner.constant;

/**
 * 收益来源
 *
 * @author Alvin Wang
 * @version 1.0.0 @ 2017-04-16
 */
public enum ProfitSourceEnum {
	ADVERTISE_PROFIT("广告收益", Byte.valueOf("1")), SECOND_ANNUAL_FEE("二级年费收益", Byte.valueOf("2")), SECOND_ADVERTISE_PROFIT("二级广告收益", Byte.valueOf("3"));

	private String name;
	private byte code;

	ProfitSourceEnum(String name, byte code) {
		this.name = name;
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public byte getCode() {
		return code;
	}

	/**
	 * 根据 code获取ProfitSourceEnum
	 *
	 * @param code
	 *            code
	 * @return {@link ProfitSourceEnum}
	 */
	public static ProfitSourceEnum getProfitSourceByCode(byte code) {
		for (ProfitSourceEnum profitSource : values()) {
			if (code == profitSource.code) {
				return profitSource;
			}
		}
		return null;
	}
}
